import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { Nyt7FarmerInsuranceInfoVO, Nyt7FarmerInsuranceInfoForm, Nyt7FarmerInsuranceInfoQuery } from '@/api/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo/types';

/**
 * 查询农户投保信息列表
 * @param query
 * @returns {*}
 */

export const listNyt7FarmerInsuranceInfo = (query?: Nyt7FarmerInsuranceInfoQuery): AxiosPromise<Nyt7FarmerInsuranceInfoVO[]> => {
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询农户投保信息详细
 * @param id
 */
export const getNyt7FarmerInsuranceInfo = (id: string | number): AxiosPromise<Nyt7FarmerInsuranceInfoVO> => {
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增农户投保信息
 * @param data
 */
export const addNyt7FarmerInsuranceInfo = (data: Nyt7FarmerInsuranceInfoForm) => {
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改农户投保信息
 * @param data
 */
export const updateNyt7FarmerInsuranceInfo = (data: Nyt7FarmerInsuranceInfoForm) => {
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除农户投保信息
 * @param id
 */
export const delNyt7FarmerInsuranceInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo/' + id,
    method: 'delete'
  });
};


export function getFarmerCount() {
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo/count',
    method: 'get'
  });
}
/**
 * 添加导入Excel的方法
 * @param file
 */
export const importExcel = (file: File) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};






/**
 * 导出选中的农户投保信息列表
 * @param ids
 */
export const exportSelected = (ids: number[]): AxiosPromise<Blob> => {
  return request({
    url: '/Nyt7FarmerInsuranceInfo/Nyt7FarmerInsuranceInfo/exportSelected',
    method: 'post',
    data: ids,
    responseType: 'blob'
  });
};